#!/usr/bin/env python
# -*- coding: UTF-8 -*-
# Edit By WangWenHao, CMIOT, China Mobile

import sys
import time
import pandas as pd
import numpy as np

def time2min(t):
	h,m = t.strip().split(":")
	return int(h) * 60 + int(m)

def min2time(min_cnt):
	h, m = divmod(min_cnt, 60)
	str = "%d:%d" % (h,m)
	return str


def str2value():
	global df
	df = pd.read_csv('../newdata_0.csv', sep = ";")
	for i in range(0, len(df)):
		bedtime = time2min(df['Time in bed'][i])
		df['Time in bed'][i] = str(bedtime)
		slpQuilty = int(df['Sleep quality'][i].strip("%"))
		df['Sleep quality'][i] = str(slpQuilty)
	df.to_csv('../newdata_1.csv', sep = ";", index =True)	



if __name__ == '__main__':
	print("Dodata start...")
	str2value()
    # print(__name__)